<?php
/**
 * @version 0.8.3 2010-10-07
 * @package Joomla
 * @subpackage LeagueResults
 * @copyright (C)  2008, 2009, 2010 Henryk Drozd
 * @license GNU/GPL, see LICENSE.php
 * LeagueResults is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License 2
 * as published by the Free Software Foundation.

 * LeagueResults is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

class lrModelPerson extends JModel
{
	var $_person = null;
	var $_id = null;
	
	function __construct()
	{
	parent::__construct();
	$id = JRequest::getVar ('id', 0);
	$this->_id = $id;
	}
	
	
	function getData()
	{
	if (!$this->_person)
		{
		$query = "SELECT  tp.id, tp.player_id, CONCAT(CONCAT(p.lastname,', '), p.firstname) AS pname,
						p.*,
						tp.team_id, t.name AS tname, tp.leagueseasons_id, s.name AS sname, s.year,
						tp.published
					FROM #__lr_teamplayers AS tp
					JOIN #__lr_players AS p ON tp.player_id = p.id
					JOIN #__lr_teams AS t ON tp.team_id = t.id				
					JOIN #__lr_leagueseasons AS s ON tp.leagueseasons_id = s.id
			 		WHERE tp.player_id ='".$this->_id."'
					ORDER BY s.year DESC";
		
/*		$query = "SELECT p.*, tp.team_id 
				FROM #__lr_players AS p
				JOIN #__lr_teamplayers AS tp ON tp.player_id = p.id
		 			 WHERE p.id ='".$this->_id."'";
	*/								
				
		$this->_person = $this->_getList($query, 0, 0);

//		$this->_db->setQuery($query);

//		$this->_player = $this->_db->loadObject();
		
		}

	return $this->_person;
	}

}

?>